# -*- coding=UTF-8 -*-
import urllib.request
import re
import os

url = 'https://tieba.baidu.com/p/2460150866?pn=1'
page = urllib.request.urlopen(url)
html = page.read().decode("utf-8")

reg = r'src="(.*?\.jpg)" pic_ext'
imgre = re.compile(reg)
imglist = re.findall(imgre, html)
x = 0 
if(not os.path.exists('..\\img')):
    os.mkdir('..\\img')
print('正在爬取图片')
for img in imglist:
    urllib.request.urlretrieve(img,"..\\img\\img%s.jpg"%x)
    x += 1
print('爬取完成')
